package com.yc.damai.web;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.yc.damai.bean.Cart;
import com.yc.damai.bean.User;
import com.yc.damai.biz.CartBiz;
import com.yc.damai.biz.CartDao;
import com.yc.damai.dao.UserDao;

@WebServlet("/qcart.s")
public class QueryCartServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private CartDao cdao = new CartDao();
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		User user = (User) request.getSession().getAttribute("loginedUser");
		List<Map<String, Object>> list =cdao.queryCartInfo(user.getUid());
		Gson g = new Gson();
		String json = g.toJson(list);
		response.getWriter().append(json);
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
